<template>
  <a-card :bordered="false">



    <!-- table区域-begin -->
    <div>


      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <span slot="amount" slot-scope="text, record">
          <span v-if='record.type==1' style='color: red'>-{{record.amount}}</span>
          <span v-if='record.type==2' style='color: green'>{{record.amount}}</span>
          <span v-if='record.type==3' style='color: green'>{{record.amount}}</span>
        </span>
        <span slot="type" slot-scope="text, record">
          <span v-if='record.type==1' style='color: red'>提现</span>
          <span v-if='record.type==2' style='color: green'>获利</span>
          <span v-if='record.type==3' style='color: green'>提现退回</span>
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction } from '@api/manage'

  export default {
    name: 'UserhomeWalletFundLogListModal',
    mixins:[JeecgListMixin, mixinDevice],
    props: {
      userhomeId: {
        type: Number,
        default: ''
      },
    },
    components: {

    },
    data () {
      return {
        description: 'userhome_wallet_fund_log管理页面',
        // 表头
        columns: [
          {
            title:'金额',
            align:"center",
            dataIndex: 'amount',
            scopedSlots: { customRender: 'amount' }
          },
          {
            title:'来源',
            align:"center",
            dataIndex: 'type',
            scopedSlots: { customRender: 'type' }
          },
          {
            title:'变化之后金额',
            align:"center",
            dataIndex: 'smoney'
          },
          {
            title:'相关订单号',
            align:"center",
            dataIndex: 'relateOrderNum'
          }
        ],
        url: {
          list: "/fund/userhomeWalletFundLog/list",
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      loadData(arg) {
        if (!this.url.list) {
          this.$message.error("请设置url.list属性!")
          return
        }
        if (this.userhomeId == null || this.userhomeId == "") {
          return
        }
        this.queryParam.userhomeId = this.userhomeId;
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        var params = this.getQueryParams();//查询条件
        this.loading = true;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            this.dataSource = res.result.records || res.result;
            if (res.result.total) {
              this.ipagination.total = res.result.total;
            } else {
              this.ipagination.total = 0;
            }
            //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          } else {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.loading = false
        })
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'userhomeId',text:'平台用户id'})
        fieldList.push({type:'number',value:'amount',text:'金额'})
        fieldList.push({type:'int',value:'type',text:'（1,减少 2增加）'})
        fieldList.push({type:'number',value:'smoney',text:'变化之后金额'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>